<?php
namespace Home\Controller;
use Think\Controller;
//header("Content-type:text/html;charset=utf-8");
class IndexController extends Controller {

    public function publicinfor(){

        $sql="select * from wx_columns where col_level=0 ";
        $columns=D()->query($sql);

        $sql="select * from wx_columns where col_level=1";
        $columns1=D()->query($sql);

        $sql="select * from wx_columns where col_level=2";
        $columns2=D()->query($sql);

        $this->assign('col1',$columns);
        $this->assign('col2',$columns1);
        $this->assign('col3',$columns2);
    }

    public function index(){
        $this->publicinfor();
        $this->display();
   }

    public function entergoods($id){
        $this->publicinfor();
//        $sql="select * from wx_columns_category LEFT  join wx_category  on wx_category.cate_id =wx_columns_category.cc_category_id where wx_columns_category.cc_columns_id=$id";
//        $category=D()->query($sql);
////        show_bug($category);
//        $sql="select * from wx_category_attribute LEFT  join wx_attribute  on wx_attribute.at_id =wx_category_attribute.attribute_id";
////        $sql="select * from wx_category_attribute LEFT  join wx_attribute  on wx_attribute.at_id =wx_category_attribute.attribute_id INNER join wx_category_attribute as catt on wx_category_attribute.category_id=catt.category_id  where catt.category_id in (select wx_category_attribute.category_id from wx_columns_category_attribute LEFT  join wx_category_attribute  on wx_category_attribute.attribute_id =wx_columns_category_attribute.ca_category_attribute_id where wx_columns_category_attribute.ca_col_id=$id)";
//        $attribute=D()->query($sql);
//        show_bug($attribute);
//        $sql="select * from wx_columns_category_attribute LEFT  join wx_category_attribute  on wx_category_attribute.attribute_id = wx_columns_category_attribute.ca_category_attribute_id where wx_columns_category_attribute.ca_col_id=$id";
//        $cate=D()->query($sql);
//        show_bug($cate);
//        $this->assign('category',$category);
//        $this->assign('attribute',$attribute);

        $sql="select * from wx_columns_category LEFT  join wx_category  on wx_category.cate_id =wx_columns_category.cc_category_id where wx_columns_category.cc_columns_id=$id";
        $category=D()->query($sql);

        $sql="select * from wx_category_attribute LEFT  join wx_attribute  on wx_attribute.at_id = wx_category_attribute.attribute_id 
              where  wx_category_attribute.attribute_id in (select wx_category_attribute.attribute_id from wx_columns_category_attribute LEFT join wx_category_attribute  on wx_category_attribute.attribute_id =wx_columns_category_attribute.ca_category_attribute_id where wx_columns_category_attribute.ca_col_id=$id)";
        $attribute=D()->query($sql);
//        show_bug($attribute);

        $sql="select *from wx_goods_columns LEFT  join wx_goods on wx_goods_columns.col_goods_goods_id =wx_goods.goods_id where wx_goods_columns.col_goods_col_id=$id";
        $goods=D()->query($sql);
//        show_bug($goods);

        $this->assign('category',$category);
        $this->assign('attribute',$attribute);
        $this->assign('goods',$goods);
        $this->display();
    }


}